﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using IdentityServer4.Models;
using IdentityServer4.Services;
using Microsoft.AspNetCore.Identity;

namespace IdentityMiddleware.IdentityProvider.Model
{
    public class ProfileServiceModel:IProfileService 
    {
        private readonly UserManager<UserModel> _userManager;
        public ProfileServiceModel(UserManager<UserModel> userManager)
        {
            _userManager = userManager;
        }

        public Task GetProfileDataAsync(ProfileDataRequestContext context)
        {
           var qqq= context.Subject.Identity.Name;
            return Task.FromResult(0);
            //throw new NotImplementedException();
        }

        public Task IsActiveAsync(IsActiveContext context)
        {
            var user = _userManager.GetUserAsync(context.Subject).Result;
            context.IsActive = user != null;
            return Task.FromResult(0);
            //throw new NotImplementedException();
        }
    }
}
